<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title><spring:message code="member.myOrder"></spring:message></title>
    <link href="${pageContext.request.contextPath }/phone/css/font/iconfont.css" rel="stylesheet" type="text/css" />
    <!--公共样式sss-->
    <link href="${pageContext.request.contextPath }/phone/css/public.css" rel="stylesheet" type="text/css" />
    <!--layer弹出-->
    <link href="${pageContext.request.contextPath }/phone/js/layer/skin/layer.css" rel="stylesheet" type="text/css" />
    <!--我的(个人中心)样式-->
    <link href="${pageContext.request.contextPath }/phone/css/mine.css" rel="stylesheet" type="text/css" />

</head>
<body>
<!--头部 begin-->
<header class="page_topbar">
    <a href="${pageContext.request.contextPath }/api/member/userCenter" class="back Hui-iconfont"></a>
    <div class="title"><spring:message code="member.myOrder"></spring:message></div>
</header>
<!--头部 end-->
<div class="content">
    <ul class="cartlist">
     <c:forEach var="list" items="${listorder}">
        <li>
            <div class="dingdb"><a href="${pageContext.request.contextPath}/api/orders/orderDetailToPaid${list.orders.O_ID}"><div class="dingdbian"><spring:message code="order.orderNo"></spring:message>：${list.orders.O_NO }</div></a>
            <div class="dingdzt">
            <c:choose>
			<c:when test="${list.orders.O_STATE==0}">
		     <spring:message code="daifukuan"></spring:message><br/>
			</c:when>
			<c:when test="${list.orders.O_STATE==1}">
			 <spring:message code="yifukuan"></spring:message><br/>
			</c:when>
			<c:when test="${list.orders.O_STATE==2}">
			 <spring:message code="yishouhuo"></spring:message><br/>
			</c:when>
			</c:choose>    
            </div>
            <div class="clearf"></div></div>
            <c:forEach items="${list.orderlist}" var="item">
            <div class="discuss-list-cont">
                <span class="discuss-list-cont-l">
                <c:choose>
					<c:when test="${item.OL_TYPE!=3}">
	                <a target="_top" href="${pageContext.request.contextPath}/api/pattern/viewpattern?pNo=${item.OL_PATTERN_NO}"><img src="${item.OL_PATTERN_IMG}" /></a>
	                </c:when>
	                <c:when test="${item.OL_TYPE==3}">
	                <a target="_top" href="${pageContext.request.contextPath}/api/pattern/viewf?fNo=${item.OL_FABRIC_NO}"><img src="${pageContext.request.contextPath }/upload/${item.MESSAGE3}" /></a>
	            	 </c:when>
	             </c:choose>
                </span>
                <span class="discuss-list-cont-r">
                <c:choose>
				<c:when test="${item.OL_TYPE==0}">
				<p><span class="dis-title"><spring:message code="pattern"></spring:message>：${item.OL_PATTERN_NO}</span><span class="dis-time">X${item.OL_FABRIC_SIZE}</span></p>
                <p><span class="dis-title w-b50">￥<fmt:formatNumber pattern="0.00"  value="${item.MESSAGE2 + 0.0001}"/></span><span class="dis-time w-b35"><spring:message code="order.printing"></spring:message> ${item.PP_NAME}</span></p>
				</c:when>
				<c:when test="${item.OL_TYPE==1}">
				<p><span class="dis-title"><spring:message code="pattern"></spring:message>：${item.OL_PATTERN_NO}</span><span class="dis-time">X${item.OL_FABRIC_SIZE}</span></p>
                <p><span class="dis-title w-b50">￥<fmt:formatNumber pattern="0.00"  value="${item.MESSAGE2 + 0.0001}"/></span><span class="dis-time w-b35"><spring:message code="order.buyout"></spring:message></span></p>
				</c:when>
				<c:when test="${item.OL_TYPE==2}">
				<p><span class="dis-title"><spring:message code="pattern"></spring:message>：${item.OL_PATTERN_NO}</span><span class="dis-time">X${item.OL_FABRIC_SIZE}</span></p>
                <p class="discuss-list-cont-detail"><spring:message code="order.fabric"></spring:message>：${item.OL_FABRIC_NO}</p>
                <p><span class="dis-title w-b50">￥<fmt:formatNumber pattern="0.00" value="${item.MESSAGE2 + 0.0001}"/></span><span class="dis-time w-b35"><spring:message code="order.finishedProduct"></spring:message> ${item.PP_NAME}</span></p>
                </c:when>
				<c:when test="${item.OL_TYPE==3}">
				<p><span class="dis-title"><spring:message code="order.fabric"></spring:message>：${item.OL_FABRIC_NO}</span><span class="dis-time">X${item.OL_FABRIC_SIZE}</span></p>
                <p><span class="dis-title w-b50">￥<fmt:formatNumber pattern="0.00"  value="${item.MESSAGE2 + 0.0001}"/></span><span class="dis-time w-b35"><spring:message code="order.fabric"></spring:message></span></p>
                </c:when>
                
				</c:choose> 
                </span>
            </div>
            </c:forEach>
            <div class="dingdbottom"><div class="jiesle"><span><spring:message code="gongji"></spring:message>${fn:length(list.orderlist)}<spring:message code="jianshangpin"></spring:message></span><span><spring:message code="jinee"></spring:message>：￥${list.orders.O_TOTAL_PRICE}</span></div>
            <c:choose>
			<c:when test="${list.orders.O_STATE==0}">
		     <div class="jies" onclick="pay(${list.orders.O_ID})"><spring:message code="qujiesuan"></spring:message></span></div>
		     </c:when>
			<c:when test="${list.orders.O_STATE==1}">
			 <div class="jies" onclick="del(${list.orders.O_ID})"><spring:message code="order.deleteOrder"></spring:message></span></div>
			</c:when>
			<c:when test="${list.orders.O_STATE==2}">
			 <div class="jies" onclick="del(${list.orders.O_ID})"><spring:message code="order.deleteOrder"></spring:message></span></div>
			</c:when>
			</c:choose>    
            <div class="clearf"></div></div>
        </li>
        
        
        
        
        </c:forEach>
    </ul>

</div>
         <div class="fenye_div">
                        <span class="fenye">
                            <button type="button" onclick="shangyiye()" class="before-page" ${pageInfo.page<=1?'disabled="disabled"':''}><spring:message code="order.previousPage"></spring:message></button>
                            <button type="button" onclick="xiayiye()" class="next-page" ${pageInfo.page>=pageInfo.totalPage?'disabled="disabled"':''}><spring:message code="order.nextPage"></spring:message></button>
                        </span>
                    </div>
		<form id="pay" target="_blank" action="${pageContext.request.contextPath}/web/orders/pay" method="post">
        <input type="hidden"  name="oId" id="oId">
        </form>
</body>
<script src="${pageContext.request.contextPath }/phone/js/jquery-1.8.3.min.js"></script>
 <script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/layer_mobile/layer.js"></script>
<script type="text/javascript">

function del(id){
	layer.open({
    	  btn: ['<spring:message code="reciveAddress.confirm"></spring:message>','<spring:message code="reciveAddress.cancel"></spring:message>'], //按钮
    	  content:'<spring:message code="reciveAddress.confirmDeletion"></spring:message>'
	,yes: function(index){
		 $.ajax({
   			 url:'${pageContext.request.contextPath }/web/orders/delorders',
   			 async : false,
   			 data: {oId:id},
   			 type : "POST", 
   			 success :function(result){
   			 var status=result.msg.status;
   			 var desc=result.msg.desc;
   			 if(status == 0){
   				layer.open({content: '<spring:message code="caozuochenggong"></spring:message>',skin: 'msg',time: 1});
	   	   		
   				 location.reload(true);
   			 }else if(status == 2){//没登录
   				layer.open({content: '<spring:message code="weidenglu"></spring:message>',skin: 'msg',time: 1});
	   	   		
   			    }else if(status ==1){//失败
   			    	layer.open({content: '<spring:message code="caozuoshibai"></spring:message>',skin: 'msg',time: 1});
   		   	   		
   			    }
   			 }
   			 });
     	},no:function(index){
     		 window.parent.layer.close(index);
     	}
     	});
}
function shangyiye(){
	var url="${pageContext.request.contextPath }/api/orders/orderslist?page="+${pageInfo.page-1};
	location.href=url;
}
function xiayiye(){
	var url="${pageContext.request.contextPath }/api/orders/orderslist?page="+${pageInfo.page+1};
	location.href=url;
}

function pay(id){
	
	$.ajax({
			 url:'${pageContext.request.contextPath }/web/orders/chakandingdan',
			 async : false,
			 data: {"oId":id},
			 type : "GET", 
			 success :function(result){
			 if(result == "SUCCESS"){
				 $("#oId").val(id);
				$("#pay").submit();
			 }else{//失败
				 layer.open({content: '<spring:message code="huaxingyibeimaiduan"></spring:message>',skin: 'msg',time: 1});
		   	   		
			 }
			 }
			 });
	
	

	
}
</script>
</html>